#JTC filter_CDMO.pl
#!/usr/bin/perl

########################################################
#get rid of extra unnecessary header and footer lines with namespaces that confuse LibXML

$filename = @ARGV[0];

open (FILE, $filename.'.txt');

my $line_feed = 0;
my $content = '';
foreach my $line (<FILE>) {
        
        if (!($line =~ /nds/) && ($line_feed == 0)) { next; } else { $line_feed = 1; }
        
        $content .= $line;
        if ($line =~ /\/nds/) { last; }
}

close (FILE);

open (FILE_OUT,">$filename".'.xml');
print FILE_OUT $content;
close(FILE_OUT);
print $content;
exit 0;
